﻿var url = new Url();
var $css = url.GetQueryString("css");
//设置分页信息
var page = new Page();
page.Url = "../Handler/LoanProductOrderHandler.ashx";
page.Dom = $("#searchArea");
page.type = 6;
page.Container = $("#dataList");
page.CallBack = function (data) {
    $(".borrowList").empty();
    $.each(data, function (index, item) {
        item.Css = $css;
        item.Verifiable = item.Verifiable ? "inline" : "none";
        item.Editable = item.Editable ? "inline" : "none";
        item.CreateContract = item.CreateContract ? "inline" : "none";
        item.Reconsider = item.Reconsider ? "inline" : "none";
        item.Printable = item.Printable ? "inline" : "none";
        item.ContractReview = item.ContractReview ? "inline" : "none";
        item.Allow = item.Allow ? "inline" : "none";
        $("#ContractTemplete").tmpl(item).appendTo($("#dataList"));
    });
};
page.GetPageData();
$(".btnDelLender").click(function () {
    $(".txtUserName").val("");
});
//搜索用户
$(".btnSearchBorrow").bind("click", function () {
    var $userName = $(".txtName").val();
    var $phone = $(".txtPhone").val();
    $.getJSON("../Handler/LoanUserInfo.ashx",
        { Name: $userName, Phone: $phone, type: 5, _: Math.random() },
        function (result) {
            $(".userInfo").empty();
            if (result.Status) {
                $(result.Data).each(function (index, item) {
                    $("#UserTemplete").tmpl(item).appendTo($(".userInfo"));
                });
                $(".userInfo tr").css("cursor", "pointer").click(function () {
                    $(".txtUserName").val($(this).find(".name").text());
                    $(".txtUserId").val($(this).find(".userId").text());
                });
            } else {
                alert(result.Message);
            }
        });
});
$(".btnDelLender").bind("click", function () {
    $(".txtuserName").val("");
    $(".txtUserId").val("");
});
$(".btnShow").bind("click", function () {
    $(".txtName").val($(".txtUserName").val());
})
$(".txtuserName").bind("click", function () {
    $(".btnShow").click();
});